package com.hzncc.flowable_diboot.dto;

import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
import com.diboot.iam.entity.IamOrg;
import com.diboot.iam.entity.IamUser;
import com.hzncc.flowable_diboot.entity.Clue;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

        import com.hzncc.flowable_diboot.entity.Customer;
/**
* 线索 DTO定义
*
* @author MyName
* @version 1.0
* @date 2024-06-14
 * Copyright © MyCorp
*/
@Getter
@Setter
@Accessors(chain = true)
public class ClueDTO extends Clue  {
private static final long serialVersionUID = 1599113116431920762L;

        /**
        * 分配日期
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime disDate;
        /**
        * 分配日期 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "dis_date")
        private LocalDate disDateBegin;

        /**
        * 分配日期 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "dis_date")
        private LocalDate disDateEnd;
        /**
        * 客户名称 关联信息
        */
        @BindQuery(entity = Customer.class, column = "name",condition = "this.customerId = id")
        private String customerName;
        /**
        * 进入线索池倒计时 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "expiration_time")
        private Long expirationTimeBegin;

        /**
        * 进入线索池倒计时 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "expiration_time")
        private Long expirationTimeEnd;
        /**
        * 是否分配（0未分配 1 已分配） 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "flag")
        private Long flagBegin;

        /**
        * 是否分配（0未分配 1 已分配） 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "flag")
        private Long flagEnd;
        /**
        * 进入线索池天数 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "enter_days")
        private Long enterDaysBegin;

        /**
        * 进入线索池天数 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "enter_days")
        private Long enterDaysEnd;
        /**
        * 进入时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime enterTime;
        /**
        * 进入时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "enter_time")
        private LocalDate enterTimeBegin;

        /**
        * 进入时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "enter_time")
        private LocalDate enterTimeEnd;
        /**
        * 创建时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime createTime;
        /**
        * 创建时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "create_time")
        private LocalDate createTimeBegin;

        /**
        * 创建时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "create_time")
        private LocalDate createTimeEnd;
        /**
        * 更新时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime updateTime;
        /**
        * 更新时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "update_time")
        private LocalDate updateTimeBegin;

        /**
        * 更新时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "update_time")
        private LocalDate updateTimeEnd;

        public LocalDate getDisDateEnd() {
            if (getDisDate() != null) {
                return getDisDate().plusDays(1).toLocalDate();
            }
            if (disDateEnd != null) {
                return disDateEnd.plusDays(1);
            }
            return null;
        }
        public LocalDate getEnterTimeEnd() {
            if (getEnterTime() != null) {
                return getEnterTime().plusDays(1).toLocalDate();
            }
            if (enterTimeEnd != null) {
                return enterTimeEnd.plusDays(1);
            }
            return null;
        }
        public LocalDate getCreateTimeEnd() {
            if (getCreateTime() != null) {
                return getCreateTime().plusDays(1).toLocalDate();
            }
            if (createTimeEnd != null) {
                return createTimeEnd.plusDays(1);
            }
            return null;
        }
        public LocalDate getUpdateTimeEnd() {
            if (getUpdateTime() != null) {
                return getUpdateTime().plusDays(1).toLocalDate();
            }
            if (updateTimeEnd != null) {
                return updateTimeEnd.plusDays(1);
            }
            return null;
        }

}